<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>对使用 MIME base64 编码的数据进行解码</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="ref.url.html">« URL 函数</a></li>
      <li style="float: right;"><a href="function.base64-encode.html">base64_encode »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.url.html">URL 函数</a></li>
    <li>对使用 MIME base64 编码的数据进行解码</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.base64-decode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">base64_decode</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">base64_decode</span> &mdash; <span class="dc-title">对使用 MIME base64 编码的数据进行解码</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.base64-decode-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>base64_decode</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$strict</code><span class="initializer"> = <strong><code>false</code></strong></span></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   对 base64 编码的 <code class="parameter">string</code> 进行解码。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.base64-decode-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">string</code></dt>

     <dd>

      <p class="para">
       编码过的数据。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">strict</code></dt>

     <dd>

      <p class="para">
       当设置 <code class="parameter">strict</code> 为 <strong><code>true</code></strong> 时，一旦输入的数据超出了 base64 字母表，将返回 <strong><code>false</code></strong>。
       否则会静默丢弃无效的字符。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.base64-decode-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回解码后数据， 或者在失败时返回 <strong><code>false</code></strong>。返回的数据可能是二进制的。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.base64-decode-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3834">
    <p><strong>示例 #1 <span class="function"><strong>base64_decode()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">base64_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
This is an encoded string
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.base64-decode-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.base64-encode.html" class="function" rel="rdfs-seeAlso">base64_encode()</a> - 使用 MIME base64 对数据进行编码</span></li>
    <li class="member">
     <a href="http://www.faqs.org/rfcs/rfc2045" class="link external">&raquo;&nbsp;RFC 2045</a> 的 6.8 章节。
     </li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>